<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>圣都家装现金抵用券</title>
  <link href="https://cdn.bootcss.com/normalize/8.0.1/normalize.min.css" rel="stylesheet">
  <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
  <style>
    * {
      box-sizing: border-box;
    }

    body {
      /*background-color: #EEBA92;*/
      background: #cbe8d6;
      font-family: "PingFang SC", "Helvetica Neue", Helvetica, Arial, "Microsoft Yahei", "Hiragino Sans GB", "Heiti SC", "WenQuanYi Micro Hei", sans-serif;
    }

    #banner {
      width: 100%;
    }

    #form {
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: center;
      margin: 0 17px 0 17px;
      background-image: url("/static/kitchen/bg2.png");
      background-repeat: no-repeat;
      background-size: 100%;
      background-position: top center;
    }

    #title1 {
      padding-top: 20px;
      text-align: center;
      /*font-size: 19px;*/
      /*color: #333;*/
    }

    #title2 {
      text-align: center;
      font-size: 25px;
      color: #333;
      line-height: 50px;
    }

    .body {
      width: 85%;
      margin-top: 45px;
    }

    #location {
      font-size: 13px;
      color: #333;
      margin-bottom: 10px;
    }

    #input {
      width: 100%;
      padding: 0 10px;
      color: #333;
      font-size: 13px;
      background-color: #f7f7f7;
      height: 40px;
      border: 1px solid #808080;
      border-radius: 5px;
      outline: none;
    }

    #btn {
      display: flex;
      justify-content: center;
      align-items: center;
      margin-top: 16px;
      height: 40px;
      width: 100%;
      margin-bottom: 25px;
      font-size: 18px;
      background-color: #f33f3e;
      color: #fff;
      border-radius: 5px;
    }

    #left-block {
      width: 80px;
      line-height: 75px;
      text-align: center;
      background-color: #f33f3e;
      border-radius: 5px;
      color: #fff;
      font-size: 12px;
    }

    #right-block {
      flex: 1;
      display: flex;
      padding: 0 10px;
      flex-direction: column;
      justify-content: center;
    }

    #btn-block {
      border: 1px solid #f33f3e;
      color: #f33f3e;
      font-size: 13px;
      padding: 5px 10px;
      border-radius: 3px;
    }

    .loading {
      display: flex;
      justify-content: center;
      align-items: center;
      top: 60px;
      width: 90px;
      height: 80px;
      background-color: rgba(0, 0, 0, 0.7);
      border-radius: 10px;
    }

    .loading span {
      display: inline-block;
      width: 6px;
      height: 0;
      margin: 0 2px;
      border-radius: 4px;
      background: #fff;
      -webkit-animation: load 1s ease infinite;
    }

    @-webkit-keyframes load {
      0%, 100% {
        height: 20px;
      }
      50% {
        height: 40px;
      }
    }

    .loading span:nth-child(2) {
      -webkit-animation-delay: 0.2s;
    }

    .loading span:nth-child(3) {
      -webkit-animation-delay: 0.4s;
    }

    .loading span:nth-child(4) {
      -webkit-animation-delay: 0.6s;
    }

    .loading span:nth-child(5) {
      -webkit-animation-delay: 0.8s;
    }

    #modal {
      display: none;
      justify-content: center;
      align-items: center;
      position: fixed;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      z-index: 999;
    }
  </style>
  <script>
    function submit() {
      document.getElementById('modal').style.display = 'flex';
      const phone = document.getElementById('input').value;
      fetch('{{ domainn }}/app/activity/', {
        method: 'POST',
        headers: {'Content-Type': 'application/json', 'X-Token': '{{ access_token }}'},
        body: JSON.stringify({phone, id: '8e44e27926ef46c1b45226d42ddc10d6'})
      }).then(res => res.json()).then(res => {
        if (res.error === '') {
          document.getElementById('modal').style.display = 'none';
          document.getElementById('init').style.display = 'none';
          document.getElementById('complete').style.display = 'flex';
          document.getElementById('q-value').textContent = res.data['value'];
          document.getElementById('q-type').textContent = res.data['type'];
          document.getElementById('q-name').textContent = res.data['name'];
          document.getElementById('q-date').textContent = '有效期至：' + res.data['expired_at'];
        } else {
          document.getElementById('modal').style.display = 'none';
          alert(res.error)
        }
      })
    }

    function goto() {
      wx.miniProgram.switchTab({url: '{{ redirect }}'})
    }

    function onBlur() {
      let isIOS = !!navigator.userAgent.match(/iPhone/);
      if (isIOS) {
        setTimeout(() => {
          const scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0
          window.scrollTo(0, Math.max(scrollHeight - 1, 0))
        }, 200)
      }
    }
  </script>
</head>
<body>
<img id="banner" src="/static/220830/activity230504.jpg" alt="banner"/>
<div>
  <div id="form">
    <!-- <div id="title1">诚邀您体验</div> -->
    <!-- <div id="title2">圣都大礼包</div> -->
    <div id="title1"><img id="banner" src="/static/220830/activity_remark.jpg" alt="activity"/></div>
    <div id="init" class="body">
      <div id="location">所在城市：<span style="color: #FC534C">上海</span></div>
      <input onblur="onBlur()" type="tel" id="input" placeholder="请输入11位手机号"/>
      <div id="btn" onclick="submit()">立即领券</div>
    </div>
    <div id="complete" class="body"
         style="display: none; flex-direction: row; margin-bottom: 25px; align-items: center">
      <div id="left-block"><span id="q-value" style="font-size: 30px; font-weight: 500"></span><span id="q-type"></span>
      </div>
      <div id="right-block">
        <div id="q-name" style="font-size: 20px"></div>
        <div id="q-date" style="font-size: 12px; margin-top: 15px"></div>
      </div>
      <div id="btn-block" onclick="goto()">去使用</div>
    </div>
  </div>
</div>
<div id="modal">
  <div class="loading">
    <span></span>
    <span></span>
    <span></span>
    <span></span>
    <span></span>
  </div>
</div>
</body>
</html>